﻿using GetSmartIDEList.Core.Ulities;
using GetSmartIDEList.Lib.Common;
using GetSmartIDEList.Lib.ORM;
using GetSmartIDEList.WebAPI.Common;
using GetSmartIDEList.WebAPI.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Data;

namespace GetSmartIDEList.Controllers
{
    /// <summary>
    /// 初始化数据的接口：清空所有数据
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    public class InitDataController : ControllerBase
    {
        [HttpGet]
        public ActionResult<IEnumerable<resultData>> InitData()
        {
            bool isFlag = ReposFunction.DeleteAllData();

            if (isFlag)
            {
                return new[]
                {
                        new resultData { id = 200, name = "操作成功" }
                    };
            }
            else
            {
                return new[]
                {
                     new resultData { id = 500, name = "操作失败" }
                    };
            }
        }
    }
}
